package com.face.managesystem.service.impl;

import com.face.managesystem.mapper.UserMapper;
import com.face.managesystem.pojo.FaceEntry;
import com.face.managesystem.pojo.UserAttendance;
import com.face.managesystem.pojo.UserInfo;
import com.face.managesystem.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public Boolean isUser(String userID) {
        return userMapper.isUser(userID);
//        return null;
    }

    @Override
    public String getUserName(String userID) {
        return userMapper.getUserName(userID);
    }

    @Override
    public Boolean addUser(UserInfo userInfo) {
        String s = UUID.randomUUID().toString();
        System.out.println("人脸注册：" + s);
//        Boolean addUser = userMapper.addUser(userInfo);
//        System.out.println("用户信息："+addUser);
        FaceEntry faceEntry = new FaceEntry(userInfo.getUserID(), new Date(), s);
//        Boolean addFace = userMapper.addFace(faceEntry);
//        System.out.println("人脸信息：" + addFace);
        return userMapper.addUser(userInfo) && userMapper.addFace(faceEntry);
//        return addUser && addFace;
    }

    @Override
    public Boolean attendance(UserAttendance userAttendance) {
        // 插入信息数据表。
        return userMapper.attendance(userAttendance);
    }

    @Override
    public List<UserInfo> userInfo() {
        return userMapper.userInfo();
    }

    @Override
    public List<UserAttendance> userAttendance(String userID) {
        return userMapper.userAttendance(userID);
    }

    @Override
    public void test() {
        System.out.println("userService 连接成功 ...........");
    }
}
